//
//  YJCCompareController.m
//  xiangzhe
//
//  Created by lyt on 16/11/7.
//  Copyright © 2016年 com.dazhebao. All rights reserved.
//

#import "YJCCompareController.h"
#import "YJCTitleRightBtn.h"

@interface YJCCompareController ()
{
    ///动态按钮箭头向下
    BOOL _downward;
}

@end

@implementation YJCCompareController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blueColor];
    
    UIButton *dynamicBtn = [YJCTitleRightBtn buttonWithType:UIButtonTypeCustom];
    
    [dynamicBtn setTitle:@"动态" forState:UIControlStateNormal];
    [dynamicBtn setImage:[UIImage imageNamed:@"ic_shouyi_rightarw"] forState:UIControlStateNormal];
    [dynamicBtn sizeToFit];
    [dynamicBtn addTarget:self action:@selector(dynamicBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.titleView = dynamicBtn;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addBtnClick)];
    
}

#pragma mark - 动态按钮点击事件
- (void)dynamicBtnClick:(UIButton *)btn{
    
    if (!_downward) {
        [UIView animateWithDuration:0 animations:^{
            btn.imageView.transform = CGAffineTransformMakeRotation(M_PI);
        }];
        _downward = YES;
        
        NSLog(@"弹窗");
        // 推出一个控制器
        //        [self presentViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#> completion:^{
        //
        //        }];
    }
    else
    {
        [UIView animateWithDuration:0 animations:^{
            btn.imageView.transform = CGAffineTransformIdentity;
        }];
        _downward = NO;
    }
    
    
}

- (void)addBtnClick{
    NSLog(@"点击了加号");
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
